<template>
	<view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" :down="downOption"
			:up="upOption">
			<view class="margin-top">
				<view class="cu-list menu">
					<view class="cu-item" v-for="(item,index) in list" :key="index">
						<view class="content flex align-center" :class="index <5?'text-orange':'text-grey'">
							<image class="cu-avatar round sm" :src="item.user.avatar" mode="aspectFill">
								<view class="flex-sub">{{item.user.nickname}} 点赞了 {{item.goods.title}}</view>
								<view>{{item.created_at}}</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import GoodsLikeApi from "@/api/goods_like"
	export default {
		name: "MsgLike",
		mixins: [MescrollMixin],
		data() {
			return {
				mescroll: null,
				upOption: {},
				downOption: {
					use: false
				},
				list: [],
			}
		},
		onShow() {
			if(this.list.length == 0){
				this.mescroll.resetUpScroll();
			}
		},
		methods: {
			upCallback(page) {
				if (page.num == 1) {
					this.list = [];
				}
				GoodsLikeApi.list({
					page: page.num,
					page_size: page.size
				}).then((res) => {
					this.list = this.list.concat(res.data);
					this.mescroll.endBySize(res.data.length, res.total);
				})
			},
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
		}
	}
</script>

<style scoped>
	.hbyw-50 {
		height: 50vw;
	}
</style>
